package com.hdax.dm.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.dto.ScheduleDto;
import com.hdax.dm.dto.TimePlanDao;
import com.hdax.dm.entity.scheduler.DmScheduler;
import com.hdax.dm.mappers.SchedulerMapper;
import com.hdax.dm.mapstrucs.ScheduleDtoMapper;
import com.hdax.dm.mapstrucs.TimePlanDtoMapper;
import com.hdax.dm.service.PriceService;
import com.hdax.dm.service.SchedulerService;
import com.hdax.dm.service.SeatService;
import com.hdax.dm.utils.response.CommonResponse;
import com.hdax.dm.utils.response.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.scheduler.Scheduler;

import java.util.List;

@Service
public class SchedulerSImpl extends ServiceImpl<SchedulerMapper,DmScheduler> implements SchedulerService {


    @Autowired
    private TimePlanDtoMapper timePlanDaoMapper;

    @Autowired
    private ScheduleDtoMapper scheduleDtoMapper;

    @Autowired
    private SeatService seatService;

    @Autowired
    private PriceService priceService;

    @Override
    public CommonResponse<List<TimePlanDao>> getTimePlan(Integer itemId) {
        QueryWrapper<DmScheduler> wrapper=new QueryWrapper<>();
        wrapper.eq("itemId",itemId);
        return ResponseUtil.returnSuccess(timePlanDaoMapper.toTargets(list(wrapper)));
    }

    @Override
    public CommonResponse<ScheduleDto> getSchedule(Long cinemaId,Long scheduleId) {
        ScheduleDto scheduleDto=new ScheduleDto();
        scheduleDto.setCinemaId(cinemaId);
        scheduleDto.setScheduleId(scheduleId);
        scheduleDto.setSeatInfoList(seatService.seatInfo(scheduleId));
        scheduleDto.setSeatPriceList(priceService.seatPrice(scheduleId));
        return ResponseUtil.returnSuccess(scheduleDto);
    }
}
